home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / semaphores / src / vacate.c < prev   
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.7 KB  |  80 lines

  1. /*
  2.     (C) 1995, 96 AROS - The Amiga Replacement OS
  3.     $Id$
  4.     $Log$
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "exec_intern.h"
  9. #include "semaphores.h"
  10.  
  11. /*****************************************************************************
  12.  
  13.     NAME */
  14.     #include <exec/semaphores.h>
  15.     #include <clib/exec_protos.h>
  16.  
  17.     __AROS_LH2(void, Vacate,
  18.  
  19. /*  SYNOPSIS */
  20.     __AROS_LA(struct SignalSemaphore  *, sigSem, A0),
  21.     __AROS_LA(struct SemaphoreMessage *, bidMsg, A1),
  22.  
  23. /*  LOCATION */
  24.     struct ExecBase *, SysBase, 91, Exec)
  25.  
  26. /*  FUNCTION
  27.     Release a lock obtained with Procure. This will even work if the
  28.     message is not yet replied - the request will be cancelled and the
  29.     message replied. In any case the ssm_Semaphore field will be set to
  30.     NULL.
  31.  
  32.     INPUTS
  33.     sigSem - Pointer to semaphore structure.
  34.     bidMsg - Pointer to struct SemaphoreMessage.
  35.  
  36.     RESULT
  37.  
  38.     NOTES
  39.  
  40.     EXAMPLE
  41.  
  42.     BUGS
  43.  
  44.     SEE ALSO
  45.     Procure()
  46.  
  47.     INTERNALS
  48.  
  49.     HISTORY
  50.     29-10-95    digulla automatically created from
  51.                 exec_lib.fd and clib/exec_protos.h
  52.  
  53. *****************************************************************************/
  54. {
  55.     __AROS_FUNC_INIT
  56.  
  57.     /* Arbitrate for the semaphore structure */
  58.     Forbid();
  59.  
  60.     /* Check if the message is still posted. */
  61.     if(bidMsg->ssm_Message.mn_Node.ln_Type==NT_MESSAGE)
  62.     {
  63.     /* Yes. Remove it from the semaphore's waiting queue. */
  64.     Remove(&bidMsg->ssm_Message.mn_Node);
  65.  
  66.     /* And reply the message. */
  67.     ReplyMsg(&bidMsg->ssm_Message);
  68.     }else
  69.     /* The semaphore is already locked. Release the lock. */
  70.     ReleaseSemaphore(sigSem);
  71.  
  72.     /* Clear the semaphore field. */
  73.     bidMsg->ssm_Semaphore=NULL;
  74.  
  75.     /* All done. */
  76.     Permit();
  77.     __AROS_FUNC_EXIT
  78. } /* Vacate */
  79.  
  80.